package com.tangula.voicenote.db

import android.database.sqlite.SQLiteDatabase
import com.tangula.android.orm.BaseDataBaseHelper
import com.tangula.voicenote.entity.NoticeEntity

open class DbCreator :com.tangula.android.orm.DbCreator {
    override fun getDataBaseName(): String {
        return "voice_note_db"
    }

    override fun getDataBaseVersion(): Int {
        return 2
    }

    override fun onCreate(db: SQLiteDatabase) {
        super.onCreate(db)
        buildDatabase(db, true)
    }

    override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
        super.onUpgrade(db, oldVersion, newVersion)
        buildDatabase(db, true)
    }

    private fun buildDatabase(db: SQLiteDatabase, force:Boolean){
        BaseDataBaseHelper.createTable(db, NoticeEntity::class.java, force)
    }
}